Developer Documentation

QuickTime 4 API Documentation

QuickTime 4 Reference

| Previous | Chapter Contents | Chapter Top | Next |

Executing the Decompression Sequence

With the effect and sample descriptions built and the decompression sequence prepared, you can now execute the effect. The function shown in Listing 12 executes a single frame of a decompression sequence.

The parameter theTime contains the number of the frame to be executed. The parameter theNumberOfSteps contains the total number of frames that will be used to run the effect.

Listing 12 Defining the RunEffect function, which executes one frame of an effect

// Decompress a single step of the effect sequence at time.
OSErr RunEffect(TimeValue theTime, int theNumberOfSteps)
{
    OSErr                   err = noErr;
    ICMFrameTimeRecord      frameTime;

    // Set the timebase time to the step of the sequence to be rendered
    SetTimeBaseValue(gTimeBase, theTime, theNumberOfSteps);

    frameTime.value.lo      = theTime;
    frameTime.value.hi      = 0;
    frameTime.scale         = theNumberOfSteps;
    frameTime.base          = 0;
    frameTime.duration      = theNumberOfSteps;
    frameTime.rate          = 0;
    frameTime.recordSize    = sizeof(frameTime);
    frameTime.frameNumber   = 1;
    frameTime.flags         = icmFrameTimeHasVirtualStartTimeAndDuration;
    frameTime.virtualStartTime.lo   = 0;
    frameTime.virtualStartTime.hi   = 0;
    frameTime.virtualDuration   = theNumberOfSteps;

    HLock(myEffectDesc);
    DecompressSequenceFrameWhen(gEffectSequenceID,
                            StripAddress(*myEffectDesc),
                            GetHandleSize(myEffectDesc),
                            0,
                            0,
                            nil,
                            &frameTime);
    HUnlock(myEffectDesc);
}

The code in Listing 13 executes an effect in 30 steps.

Listing 13 Executing an effect directly by calling the RunEffect function

for (currentTime = 0; currentTime < 30; currentTime++)
{
    myErr = RunEffect(currentTime, 30);
    if (myErr != noErr)
        goto bail;
}

© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |